// =====================================================================
//
//  This file is part of the Microsoft Dynamics CRM SDK code samples.
//
//  Copyright (C) Microsoft Corporation.  All rights reserved.
//
//  This source code is intended only as a supplement to Microsoft
//  Development Tools and/or on-line documentation.  See these other
//  materials for detailed information regarding Microsoft code samples.
//
//  THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//  PARTICULAR PURPOSE.
//
// =====================================================================
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;
using Microsoft.Xrm.Sdk.Temporary;

namespace Microsoft.Crm.Sdk.Messages
{
	/// <summary>
	/// Defines an AppointmentProposal in Services layer.
	/// </summary>
	[DataContract(Namespace = "http://schemas.microsoft.com/crm/2011/Contracts")]
	public sealed class AppointmentProposal : IExtensibleDataObject
	{
		/// <summary>
		/// Even though this constructor does not do anything, it is still needed because 
		/// XmlSerializer requires public default constructor on the class to be serialized.
		/// </summary>
		public AppointmentProposal()
		{
		}

		/// <summary>
		/// Initializes an AppointmentProposal object.
		/// </summary>
		/// <param name="start">Start of the proposed appointment.</param>
		/// <param name="end">End of the proposed appointment.</param>
		/// <param name="siteId">
		///		Identifier of the site all proposal resources belong to,
		///		or Guid.Empty if resources belong to different sites.</param>
		/// <param name="siteName">
		///		Name of the site all proposal resources belong to,
		///		or string.Empty if resources belong to different sites.</param>
		/// <param name="proposalParties">Parties included in the proposed appointment.</param>
		public AppointmentProposal(DateTime? start, DateTime? end, Guid siteId, string siteName, ProposalParty[] proposalParties)
		{
			this.Start = start;
			this.End = end;
			this.SiteId = siteId;
			this.SiteName = siteName;
			this.ProposalParties = proposalParties;
		}

		/// <summary>
		/// Start of the proposed appointment.
		/// </summary>
		[DataMember]
		public DateTime? Start { get; set; }

		/// <summary>
		/// End of the proposed appointment.
		/// </summary>
		[DataMember]
		public DateTime? End { get; set; }

		/// <summary>
		/// Unique identificator of the site, if all resources in the proposal belong to the same site.
		/// Guid.Empty othersise.
		/// </summary>
		[DataMember]
		public Guid SiteId { get; set; }

		/// <summary>
		/// Name of the site, if all resources in the proposal belong to the same site.
		/// String.Empty othersise.
		/// </summary>
		[DataMember]
		public string SiteName { get; set; }

		/// <summary>
		/// Parties included in the proposed appointment.
		/// </summary>
		[DataMember]
		[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "Needed to ensure backward compatibility")]
		public ProposalParty[] ProposalParties { get; set; }

		#region IExtensibleDataObject Implementation
		private ExtensionDataObject _extensionDataObject;
		public ExtensionDataObject ExtensionData
		{
			get
			{
				return _extensionDataObject;
			}
			set
			{
				_extensionDataObject = value;
			}
		}
		#endregion IExtensibleDataObject Implementation
	}
}
